package com.taoxi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.taoxi.common.annotation.Log;
import com.taoxi.common.core.controller.BaseController;
import com.taoxi.common.core.domain.AjaxResult;
import com.taoxi.common.enums.BusinessType;
import com.taoxi.system.domain.Customization;
import com.taoxi.system.service.ICustomizationService;
import com.taoxi.common.utils.poi.ExcelUtil;
import com.taoxi.common.core.page.TableDataInfo;

/**
 * 定制单管理Controller
 *
 * @author ruoyi
 * @date 2024-10-14
 */
@Api(tags = "定制单管理Controller")
@RestController
@RequestMapping("/system/customization")
public class CustomizationController extends BaseController
{
    @Autowired
    private ICustomizationService customizationService;

    /**
     * 查询定制单管理列表
     */
    @ApiOperation("查询定制单管理列表")
    @PreAuthorize("@ss.hasPermi('system:customization:list')")
    @GetMapping("/list")
    public TableDataInfo list(Customization customization)
    {
        startPage();
        List<Customization> list = customizationService.selectCustomizationList(customization);
        return getDataTable(list);
    }

    /**
     * 导出定制单管理列表
     */
    @ApiOperation("导出定制单管理列表")
    @PreAuthorize("@ss.hasPermi('system:customization:export')")
    @Log(title = "定制单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Customization customization)
    {
        List<Customization> list = customizationService.selectCustomizationList(customization);
        ExcelUtil<Customization> util = new ExcelUtil<Customization>(Customization.class);
        util.exportExcel(response, list, "定制单管理数据");
    }

    /**
     * 获取定制单管理详细信息
     */
    @ApiOperation("获取定制单管理详细信息")
    @PreAuthorize("@ss.hasPermi('system:customization:query')")
    @GetMapping(value = "/{customId}")
    public AjaxResult getInfo(@PathVariable("customId") Long customId)
    {
        return success(customizationService.selectCustomizationByCustomId(customId));
    }

    /**
     * 新增定制单管理
     */
    @ApiOperation("新增定制单管理")
    @PreAuthorize("@ss.hasPermi('system:customization:add')")
    @Log(title = "定制单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Customization customization)
    {
        return toAjax(customizationService.insertCustomization(customization));
    }

    /**
     * 修改定制单管理
     */
    @ApiOperation("修改定制单管理")
    @PreAuthorize("@ss.hasPermi('system:customization:edit')")
    @Log(title = "定制单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Customization customization)
    {
        return toAjax(customizationService.updateCustomization(customization));
    }

    /**
     * 删除定制单管理
     */
    @ApiOperation("删除定制单管理")
    @PreAuthorize("@ss.hasPermi('system:customization:remove')")
    @Log(title = "定制单管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{customIds}")
    public AjaxResult remove(@PathVariable Long[] customIds)
    {
        return toAjax(customizationService.deleteCustomizationByCustomIds(customIds));
    }
}
